<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="s_search" :rules="rules" label-width="100px" id="mvcfm">
      <el-select v-model="s_search.setup_id" @change="list_s_setup" placeholder='认证类型'>
        <el-option label="认证类型" value='' />
        <el-option v-for="dict in s_setup" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
      </el-select>
      <el-select v-model="s_search.certificate_type" @change="list_s_type" placeholder='证书类型'>
        <el-option label="证书类型" value='' />
        <el-option v-for="dict in s_type" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
      </el-select>
      <div class="el-select">
        <el-input v-model="s_search.s_certificate_num" placeholder='证书编号' />
      </div>
      <el-button @click="getPage(1);" type='primary' size="mini"><i class='fa fa-search'></i>搜索</el-button>
      <el-button @click="gotoPage('/mes/certificate/CertificateIncrease?'+vueparams+'')" type='success' size="mini"><i class='fa fa-plus'></i>增加证书</el-button>
      <div>
      </div>
      <el-table :data="pageList" v-loading="loading">
        <el-table-column label="操作" align="center" width='100' type=''>
          <template slot-scope="scope">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                  <el-link @click="d_cer('&CMIDcertificate_id='+scope.row.certificate_id+'')">删除</el-link>
                </el-dropdown-item>
                <el-dropdown-item>
                  <el-link @click="gotoPage('/mes/certificate/ModeCertificate?CMIDcertificate_id='+scope.row.certificate_id+''+vueparams+'')">修改</el-link>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
        <el-table-column label="#" align="center" type='index'>
        </el-table-column>
        <el-table-column label="证书编号" prop="certificate_id">
          <template slot-scope="scope">
            <el-link @click="gotoPage('/mes/certificate/CertificateDetails?CMIDcertificate_id='+scope.row.certificate_id+''+vueparams+'')" type='primary'>{{scope.row.certificate_num}}</el-link>
          </template>
        </el-table-column>
        <el-table-column label="认证类型" prop="setup_id_desc">
        </el-table-column>
        <el-table-column label="证书类型" prop="certificate_type_desc">
        </el-table-column>
        <el-table-column label="委托人" prop="applicant_client_desc">
        </el-table-column>
        <el-table-column label="生产者" prop="engin_client_id_desc">
        </el-table-column>
        <el-table-column label="生产厂" prop="production_plant_desc">
        </el-table-column>
        <el-table-column label="产品名称" prop="cer_product_name" :show-overflow-tooltip="true">
        </el-table-column>
        <el-table-column label="型号" prop="cer_model" :show-overflow-tooltip="true">
        </el-table-column>
        <el-table-column label="规格" prop="cer_norm" :show-overflow-tooltip="true">
        </el-table-column>
        <el-table-column label="使用标准" prop="cer_standard_name" :show-overflow-tooltip="true">
        </el-table-column>
        <el-table-column label="发证日期" prop="issue_date">
        </el-table-column>
        <el-table-column label="证书截止日期" prop="validity_date">
        </el-table-column>
        <el-table-column label="状态" prop="certificate_state">
          <template slot-scope="scope">
            {{getValueName("有效=1,失效=2",scope.row.certificate_state)}}
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :limit.sync="pageSize" @pagination="getPage" />
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'CertificateStatistics',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        s_search: {
          setup_id: null,
          certificate_type: null,
          s_certificate_num: null,
        },
        ajaxObject: [],
        s_setup: [],
        s_type: [],
        loading: true,
        pageList: [],
        pageSize: 10,
        total: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.getPage(1);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/certificate/CertificateAction/certificateStatistics?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_cer(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/mes/certificate/CertificateAction/d_cer?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      getPage(page) {
        this.loading = true;
        this.s_search.pageNo = page.page || page;
        this.s_search.pageSize = page.limit || 10;
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/certificate/CertificateAction/s_cer?' + this.vueparams,
          params: this.s_search
        }).then(data => {
          this.loading = false;
          this.pageList = data.rows;
          this.total = data.total;
        })
      },
      list_s_setup(value) {
        request({
          method: 'get',
          params: {
            htmltable: '',
            cfield_name: "certificate_type",
            setup_id: value
          }
        }).then(data => {
          this.$set(this.s_search, 'certificate_type', '');
          this.s_type = data['certificate_type'];
        })
      },
      list_s_type(value) {
        request({
          method: 'get',
          params: {
            htmltable: '',
            cfield_name: "",
            certificate_type: value
          }
        }).then(data => {
          this.$set(this.s_search, '', '');
          this.$set(this.s_search, '', '');
          this.$set(this.ajaxObject, '', '');
          this.s_cer = data[''];
          this.$set(this.ajaxObject, '', '');
          this.$set(this.ajaxObject, '', '');
          this.d_cer = data[''];
          this.$set(this.ajaxObject, '', '');
          this.$set(this.ajaxObject, '', '');
          this.$set(this.ajaxObject, '', '');
          this.$set(this.ajaxObject, '', '');
          this.$set(this.ajaxObject, '', '');
          this.$set(this.ajaxObject, '', '');
          this.$set(this.ajaxObject, '', '');
          this.$set(this.ajaxObject, '', '');
          this.$set(this.ajaxObject, '', '');
          this.$set(this.ajaxObject, '', '');
          this.$set(this.ajaxObject, '', '');
          this.$set(this.ajaxObject, '', '');
          this.$set(this.ajaxObject, '', '');
          this.$set(this.ajaxObject, '', '');
          this.$set(this.ajaxObject, '', '');
        })
      },
    },
  }
</script>
